<?php
session_start();
require_once"../admin/conexao.jsp";

       $request= strtoupper($_REQUEST["search"]);
       $tabela = $_REQUEST["tabela"];
       $cod    = $_REQUEST["cod"];
       $nome   = $_REQUEST["nome"];


function live($request, $tabela, $cod, $nome){


        $sql = "select
                    $cod, $nome
                  from
                    $tabela
                  where
                    $nome like ('%{$request}%')
                  order by
                    $nome
                   ";

//        echo $sql;
        $linha=$_SESSION['ADOCnn']->Execute("$sql");
        if($linha->RecordCount() != 0 ){
           echo "<select id=\"liveSelected\" class=\"liveSelect\" size=\"10\">\n";
           while(!$linha->EOF){
      			echo "<option value=\"{$linha->fields[0]}\">" . htmlentities(trim($linha->fields[1])) ."</option>\n";
               $linha->MoveNext();
           }
           echo "</select>\n";
        }
        /*
        else{
           echo "<select id=\"liveSelected\" class=\"liveSelect\" size=\"10\">
           <option value=''>$request</optin>
           </select>\n";
        }
        */

}


live($request, $tabela, $cod, $nome);

?>



